package com.ruoyi.business.rule.service.impl;


import com.ruoyi.business.base.JoBaseServiceImpl;
import com.ruoyi.business.rule.domain.JbOrderCoefficientRules;
import com.ruoyi.business.rule.domain.vo.JbOrderCoefficientRulesVo;
import com.ruoyi.business.rule.mapper.JbOrderCoefficientRulesMapper;
import com.ruoyi.business.rule.service.JbOrderCoefficientRulesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.StringJoiner;

/**
 * 业务规则Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Service
@Slf4j
public class JbOrderCoefficientRulesServiceImpl
        extends JoBaseServiceImpl<JbOrderCoefficientRulesMapper, JbOrderCoefficientRules>
        implements JbOrderCoefficientRulesService
{

    @Override
    public List<JbOrderCoefficientRulesVo> listAll(JbOrderCoefficientRules jbOrderCoefficientRules)
    {
        StringJoiner sql = new StringJoiner("").add("""
                SELECT
                    sd.dept_id,
                	sd.dept_name,
                	sd.channel,
                	ocr.*\s
                FROM
                	sys_dept sd
                	LEFT JOIN jb_order_coefficient_rules ocr ON sd.dept_id = ocr.dept_id\s
                	 and ocr.del_flag=0
                WHERE
                	sd.del_flag = 0\s
                	AND sd.LEVEL =2
                """);
        return joSqlUtil.jsonToEntity(
                baseMapper.findJson(sql.toString()), JbOrderCoefficientRulesVo.class);
    }
}
